//
//  RootViewController.m
//  滤镜
//
//  Created by dllo on 15/12/8.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "ImageUtil.h"
#import "ColorMatrix.h"

@interface RootViewController ()

@property (nonatomic, retain) UIImageView *imageV;
@property (nonatomic, retain) UIButton *button;
@end

@implementation RootViewController

- (void)dealloc
{
    [_imageV release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.imageV = [[UIImageView alloc] initWithFrame:self.view.frame];
    self.imageV.userInteractionEnabled = YES;
    self.imageV.image = [UIImage imageNamed:@"image1.jpg"];
    [self.view addSubview:self.imageV];
    [self.imageV release];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.frame =  CGRectMake(50, 50, 50, 50);
    self.button.backgroundColor = [UIColor redColor];
    [self.button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.imageV addSubview:self.button];
    
    
    
    
}
- (void)buttonAction
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"滤镜" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    [alert addAction:[UIAlertAction actionWithTitle:@"黑白" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        self.imageV.image = [ImageUtil imageWithImage:[UIImage imageNamed:@"image1.jpg"] withColorMatrix:colormatrix_heibai];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"淡雅" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        self.imageV.image = [ImageUtil imageWithImage:[UIImage imageNamed:@"image1.jpg"] withColorMatrix:colormatrix_danya];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"哥特" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        self.imageV.image = [ImageUtil imageWithImage:[UIImage imageNamed:@"image1.jpg"] withColorMatrix:colormatrix_gete];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"复古" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        self.imageV.image = [ImageUtil imageWithImage:[UIImage imageNamed:@"image1.jpg"] withColorMatrix:colormatrix_huajiu];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"浪漫" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
        
        self.imageV.image = [ImageUtil imageWithImage:[UIImage imageNamed:@"image1.jpg"] withColorMatrix:colormatrix_langman];
    }]];
    [self presentViewController:alert animated:YES completion:^{
        
        
    }];
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
